package javase2.day02;

import java.util.Arrays;
import java.util.Scanner;

public class Demo3 {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    String rule = 
      "^\\s*[a-dA-D]([\\s,]\\s*[a-dA-D]){0,3}\\s*$";
    String ans;
    for(;;){
      System.out.print("����𰸣�");
      ans = in.nextLine();
      if(ans.matches(rule)){
        break;
      }
      System.out.println("���ˣ�Orz"); 
    }
    ans = ans.trim().toUpperCase();
    String[] answers = ans.split("[\\s,]\\s*");
    Arrays.sort(answers);
    System.out.println(Arrays.toString(answers));
  }
}
